import java.util.Iterator;
import java.util.LinkedList;

public class Stack {
    private LinkedList<Object> linkedlist = new LinkedList<Object>();
    private int top = -1;
    public void push(Object value) {
        this.setTop(this.getTop() + 1);
        linkedlist.addFirst(value);
    }
    public Object pop() {
        Object temp = linkedlist.getFirst();
        this.setTop(this.getTop() - 1);
        linkedlist.removeFirst();
        return temp;
    }
    public Object top() {
        return linkedlist.getFirst();
    }
    public Iterator<Object> iterator(){
        Iterator<Object> it = linkedlist.iterator();
        return it;	
    }
	public int getTop() {
		return top;
	}
	public void setTop(int top) {
		this.top = top;
	}
}